<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body>
    <header class="aui-bar aui-bar-nav " style="background-color: #f7911b;height: 3rem;">
        <a class="aui-pull-left"><span class="aui-iconfont aui-icon-left" onclick="api.closeWin()"></span></a>
        <div class="aui-title">设置密码</div>
    </header>

    <div class="aui-content aui-margin-t-15">
        <ul class="aui-list aui-select-list">
            <li class="aui-list-item">
              <i class="aui-iconfont aui-icon-lock"></i>
                <div class="aui-list-item-inner">
                  <input placeholder="原密码" type="password" id="oldPassword">
                </div>
            </li>
            <li class="aui-list-item">
                <i class="aui-iconfont aui-icon-lock"></i>
                <div class="aui-list-item-inner">
                  <input type="password" placeholder="新密码" id="newPassword">
                </div>
            </li>
            <li class="aui-list-item">
              <i class="aui-iconfont aui-icon-lock"></i>
                <div class="aui-list-item-inner">
                  <input  type="password" placeholder="重复新密码" id="reNewPassword">
                </div>
            </li>
        </ul>
    </div>
    <p>
        <div class="aui-btn aui-btn-block aui-btn-warning aui-margin-t-10" onclick="right()">确定</div>
    </p>
</body>
<script type="text/javascript">

    apiready = function() {

    }
        var token='';
        function right() {
          var oldPassword = $api.byId('oldPassword');
          var newPassword = $api.byId('newPassword');
          oldPasswordValue=oldPassword.value;
          newPasswordValue=newPassword.value;
          var body={
            token:$api.getStorage('token'),
            oldPassword:oldPasswordValue,
            newPassword:newPasswordValue
          };
          if(newPasswordValue===$api.byId('reNewPassword').value && newPasswordValue!='' &&$api.byId('reNewPassword').value!=''){
            api.ajax({
                url: 'http://www.mk517.com/webApi/setPassword.php',
                method: 'post',
                dataType: 'json',
                "headers":{
                  "Content-Type":"application/json"
                },
                data: {
                    body:body
                }
            }, function(ret, err) {
                if (ret) {
                  api.alert({
                      msg: '修改成功',
                  }, function(ret, err){
                      if( ret ){
                             api.closeFrame();
                      }else{
                          //  alert( JSON.stringify( err ) );
                      }
                  });
                } else {
                    // alert(JSON.stringify(err));
                }
            });
          }else {
            api.alert({
                msg: '两次密码不一致',
            }, function(ret, err){
                if( ret ){
                }else{
                    //  alert( JSON.stringify( err ) );
                }
            });
          }

        };


</script>

</html>
